class Solution(object):
    def isHappy(self, n):
        """
        :type n: int
        :rtype: bool
        """
        process = set()
        def trans(i):
            sl = [int(c) for c in str(i)]
            return sum(map(lambda x:x*x, sl))
        while n not in process:
            print(n)
            process.add(n)
            n = trans(n)
            if n==1: return True
        return False

print(Solution().isHappy(98))
